package prog.view;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import prog.model.Project;
import prog.Main;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.ImageIcon;
import javax.swing.tree.TreePath;
/*
 * ToolBarPanel.java
 *
 * Created on Jan 3, 2011, 1:38:14 PM
 */

/**
 *
 * @author MrKhoai
 */
public final class ToolBarPanel extends javax.swing.JPanel {

    /** Creates new form ToolBarPanel */
    public ToolBarPanel() {
        initComponents();
        addListenner();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    //@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jCheckBox2 = new javax.swing.JCheckBox();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        tbar_mainMenu = tbar_mainMenu = new javax.swing.JToolBar() {
            @Override
            public void paint(Graphics g) {
                Graphics2D graph=(Graphics2D)g;
                Image img = Toolkit.getDefaultToolkit().getImage("resource/Toolbar1.png");
                graph.drawImage(img, 0, 0, this);
                super.paint(g);
            }
        };
        bt_newProject = new javax.swing.JButton();
        bt_newProject.setIcon(new javax.swing.ImageIcon("resource/tool/NewProject.png"));
        bt_newProject_Wizard = new javax.swing.JButton();
        bt_newProject_Wizard.setIcon(new javax.swing.ImageIcon("resource/tool/NewProjectWizard.png"));
        jSeparator1 = new javax.swing.JToolBar.Separator();
        bt_startDown1 = new javax.swing.JButton();
        bt_startDown1.setIcon(new javax.swing.ImageIcon("resource/tool/StartDown.png"));
        bt_pauseDown1 = new javax.swing.JButton();
        bt_pauseDown1.setIcon(new javax.swing.ImageIcon("resource/tool/SupendDown.png"));
        bt_stopDown1 = new javax.swing.JButton();
        bt_stopDown1.setIcon(new javax.swing.ImageIcon("resource/tool/StopDown.png"));
        jSeparator2 = new javax.swing.JToolBar.Separator();
        jPanel2 = new javax.swing.JPanel();
        tbar_option = tbar_option = new javax.swing.JToolBar() {
            @Override
            public void paint(Graphics g) {
                Graphics2D graph=(Graphics2D)g;
                Image img = Toolkit.getDefaultToolkit().getImage("resource/Toolbar1.png");
                graph.drawImage(img, 0, 0, this);
                super.paint(g);
            }
        };
        jPanel5 = new javax.swing.JPanel();
        cb_textEx = new javax.swing.JCheckBox();
        bt_textEx = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        jPanel6 = new javax.swing.JPanel();
        cb_audioEx = new javax.swing.JCheckBox();
        bt_audioEx = new javax.swing.JButton();
        cb_videoEx = new javax.swing.JCheckBox();
        bt_videoEx = new javax.swing.JButton();
        cb_imgEx = new javax.swing.JCheckBox();
        bt_imgEx = new javax.swing.JButton();
        cb_archiveEx = new javax.swing.JCheckBox();
        bt_archiveEx = new javax.swing.JButton();
        cb_userdefinedEx = new javax.swing.JCheckBox();
        bt_userdefinedEx = new javax.swing.JButton();
        cb_otherEx = new javax.swing.JCheckBox();
        bt_otherEx = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JToolBar.Separator();
        bt_protocol = new javax.swing.JButton();
        bt_protocol.setIcon(new javax.swing.ImageIcon("resource/tool/Protocol.png"));
        jPanel3 = new javax.swing.JPanel();
        tbar_download = tbar_download = new javax.swing.JToolBar() {
            @Override
            public void paint(Graphics g) {
                Graphics2D graph=(Graphics2D)g;
                Image img = Toolkit.getDefaultToolkit().getImage("resource/Toolbar1.png");
                graph.drawImage(img, 0, 0, this);
                super.paint(g);
            }
        };
        bt_startDownAll = new javax.swing.JButton();
        bt_startDownAll.setIcon(new javax.swing.ImageIcon("resource/tool/StartDownAll.png"));
        jSeparator5 = new javax.swing.JToolBar.Separator();
        bt_stopDownAll = new javax.swing.JButton();
        bt_stopDownAll.setIcon(new javax.swing.ImageIcon("resource/tool/StopDownAll.png"));
        jSeparator6 = new javax.swing.JToolBar.Separator();
        bt_resumeDownAll = new javax.swing.JButton();
        bt_resumeDownAll.setIcon(new javax.swing.ImageIcon("resource/tool/ResumeDownAll.png"));
        jPanel4 = new javax.swing.JPanel();
        tbar_advancer = tbar_advancer = new javax.swing.JToolBar() {
            @Override
            public void paint(Graphics g) {
                Graphics2D graph=(Graphics2D)g;
                Image img = Toolkit.getDefaultToolkit().getImage("resource/Toolbar1.png");
                graph.drawImage(img, 0, 0, this);
                super.paint(g);
            }
        };

        jCheckBox2.setText("jCheckBox2");

        jTabbedPane1.setBackground(new java.awt.Color(208, 227, 227));

        tbar_mainMenu.setFloatable(false);
        tbar_mainMenu.setRollover(true);
        tbar_mainMenu.setDoubleBuffered(true);
        tbar_mainMenu.setOpaque(false);

        bt_newProject.setText("Tạo dự án mới");
        bt_newProject.setToolTipText("Tạo mới một dự án");
        bt_newProject.setActionCommand("pushNewProject");
        bt_newProject.setDoubleBuffered(true);
        bt_newProject.setFocusable(false);
        bt_newProject.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        bt_newProject.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bt_newProject.setOpaque(false);
        bt_newProject.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tbar_mainMenu.add(bt_newProject);

        bt_newProject_Wizard.setText("Tạo mới dự án theo hướng dẫn");
        bt_newProject_Wizard.setActionCommand("pushNewProject_Wizard");
        bt_newProject_Wizard.setFocusable(false);
        bt_newProject_Wizard.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bt_newProject_Wizard.setMaximumSize(new java.awt.Dimension(75, 73));
        bt_newProject_Wizard.setMinimumSize(new java.awt.Dimension(75, 73));
        bt_newProject_Wizard.setOpaque(false);
        bt_newProject_Wizard.setPreferredSize(new java.awt.Dimension(75, 73));
        bt_newProject_Wizard.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        bt_newProject_Wizard.setEnabled(false);
        tbar_mainMenu.add(bt_newProject_Wizard);
        tbar_mainMenu.add(jSeparator1);

        bt_startDown1.setText("Bắt đầu");
        bt_startDown1.setActionCommand("pushStartSelection");
        bt_startDown1.setEnabled(false);
        bt_startDown1.setFocusable(false);
        bt_startDown1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bt_startDown1.setMaximumSize(new java.awt.Dimension(75, 73));
        bt_startDown1.setMinimumSize(new java.awt.Dimension(75, 73));
        bt_startDown1.setOpaque(false);
        bt_startDown1.setPreferredSize(new java.awt.Dimension(75, 73));
        bt_startDown1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tbar_mainMenu.add(bt_startDown1);

        bt_pauseDown1.setText("Tạm dừng");
        bt_pauseDown1.setActionCommand("pushPauseSelection");
        bt_pauseDown1.setEnabled(false);
        bt_pauseDown1.setFocusable(false);
        bt_pauseDown1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bt_pauseDown1.setMaximumSize(new java.awt.Dimension(75, 73));
        bt_pauseDown1.setMinimumSize(new java.awt.Dimension(75, 73));
        bt_pauseDown1.setOpaque(false);
        bt_pauseDown1.setPreferredSize(new java.awt.Dimension(75, 73));
        bt_pauseDown1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tbar_mainMenu.add(bt_pauseDown1);

        bt_stopDown1.setText("Dừng");
        bt_stopDown1.setActionCommand("pushStopSelection");
        bt_stopDown1.setEnabled(false);
        bt_stopDown1.setFocusable(false);
        bt_stopDown1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bt_stopDown1.setMaximumSize(new java.awt.Dimension(75, 73));
        bt_stopDown1.setMinimumSize(new java.awt.Dimension(75, 73));
        bt_stopDown1.setOpaque(false);
        bt_stopDown1.setPreferredSize(new java.awt.Dimension(75, 73));
        bt_stopDown1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tbar_mainMenu.add(bt_stopDown1);
        tbar_mainMenu.add(jSeparator2);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tbar_mainMenu, javax.swing.GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tbar_mainMenu, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Menu chính", jPanel1);

        tbar_option.setFloatable(false);
        tbar_option.setRollover(true);
        tbar_option.setOpaque(false);

        jPanel5.setMaximumSize(new java.awt.Dimension(100, 100));
        jPanel5.setOpaque(false);
        jPanel5.setPreferredSize(new java.awt.Dimension(100, 75));

        cb_textEx.setSelected(true);
        cb_textEx.setActionCommand("checkCbText");
        cb_textEx.setOpaque(false);

        bt_textEx.setText("Văn bản");
        bt_textEx.setActionCommand("pushBtText");
        bt_textEx.setContentAreaFilled(false);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(cb_textEx)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bt_textEx)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(bt_textEx)
                    .addComponent(cb_textEx))
                .addContainerGap(25, Short.MAX_VALUE))
        );

        tbar_option.add(jPanel5);
        tbar_option.add(jSeparator3);

        jPanel6.setMaximumSize(new java.awt.Dimension(340, 100));
        jPanel6.setOpaque(false);

        cb_audioEx.setSelected(true);
        cb_audioEx.setActionCommand("checkCbAudio");
        cb_audioEx.setOpaque(false);

        bt_audioEx.setText("Âm thanh");
        bt_audioEx.setActionCommand("pushBtAudio");
        bt_audioEx.setContentAreaFilled(false);

        cb_videoEx.setSelected(true);
        cb_videoEx.setActionCommand("checkCbVideo");
        cb_videoEx.setOpaque(false);

        bt_videoEx.setText("Phim");
        bt_videoEx.setActionCommand("pushBtVideo");
        bt_videoEx.setContentAreaFilled(false);

        cb_imgEx.setSelected(true);
        cb_imgEx.setActionCommand("checkCbImg");
        cb_imgEx.setOpaque(false);

        bt_imgEx.setText("Hình ảnh");
        bt_imgEx.setActionCommand("pushBtImg");
        bt_imgEx.setContentAreaFilled(false);

        cb_archiveEx.setSelected(true);
        cb_archiveEx.setActionCommand("checkCbArchive");
        cb_archiveEx.setOpaque(false);

        bt_archiveEx.setText("Tệp tin nén");
        bt_archiveEx.setActionCommand("pushBtArchive");
        bt_archiveEx.setContentAreaFilled(false);

        cb_userdefinedEx.setSelected(true);
        cb_userdefinedEx.setActionCommand("checkCbUserdefined");
        cb_userdefinedEx.setOpaque(false);

        bt_userdefinedEx.setText("Tự định nghĩa");
        bt_userdefinedEx.setActionCommand("pushBtUserdefined");
        bt_userdefinedEx.setContentAreaFilled(false);

        cb_otherEx.setSelected(true);
        cb_otherEx.setActionCommand("checkCbOther");
        cb_otherEx.setOpaque(false);

        bt_otherEx.setText("Khác");
        bt_otherEx.setActionCommand("pushBtOther");
        bt_otherEx.setContentAreaFilled(false);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(cb_audioEx)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_audioEx, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(cb_videoEx)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_videoEx, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(cb_imgEx)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_imgEx, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(cb_archiveEx)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_archiveEx, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(cb_userdefinedEx)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_userdefinedEx))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(cb_otherEx)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_otherEx, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(bt_audioEx)
                                    .addComponent(cb_imgEx))
                                .addComponent(cb_audioEx))
                            .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(bt_imgEx)
                                .addComponent(cb_userdefinedEx)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cb_videoEx)
                            .addComponent(bt_videoEx)
                            .addComponent(cb_archiveEx)
                            .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(bt_archiveEx)
                                .addComponent(cb_otherEx))))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(bt_userdefinedEx)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_otherEx)))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        tbar_option.add(jPanel6);
        tbar_option.add(jSeparator4);

        bt_protocol.setText("Giao thức");
        bt_protocol.setActionCommand("pushBtProtocol");
        bt_protocol.setEnabled(false);
        bt_protocol.setFocusable(false);
        bt_protocol.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bt_protocol.setMaximumSize(new java.awt.Dimension(75, 73));
        bt_protocol.setMinimumSize(new java.awt.Dimension(75, 73));
        bt_protocol.setOpaque(false);
        bt_protocol.setPreferredSize(new java.awt.Dimension(75, 73));
        bt_protocol.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tbar_option.add(bt_protocol);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tbar_option, javax.swing.GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tbar_option, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Thiết lập", jPanel2);

        tbar_download.setFloatable(false);
        tbar_download.setRollover(true);
        tbar_download.setDoubleBuffered(true);
        tbar_download.setOpaque(false);

        bt_startDownAll.setText("Bắt đầu tất cả");
        bt_startDownAll.setActionCommand("pushStartAll");
        bt_startDownAll.setFocusable(false);
        bt_startDownAll.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bt_startDownAll.setOpaque(false);
        bt_startDownAll.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tbar_download.add(bt_startDownAll);
        tbar_download.add(jSeparator5);

        bt_stopDownAll.setText("Dừng tất cả");
        bt_stopDownAll.setActionCommand("pushStopAll");
        bt_stopDownAll.setFocusable(false);
        bt_stopDownAll.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bt_stopDownAll.setMaximumSize(new java.awt.Dimension(75, 73));
        bt_stopDownAll.setMinimumSize(new java.awt.Dimension(75, 73));
        bt_stopDownAll.setOpaque(false);
        bt_stopDownAll.setPreferredSize(new java.awt.Dimension(75, 73));
        bt_stopDownAll.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tbar_download.add(bt_stopDownAll);
        tbar_download.add(jSeparator6);

        bt_resumeDownAll.setText("Tiếp tục tất cả");
        bt_resumeDownAll.setActionCommand("pushResumeAll");
        bt_resumeDownAll.setFocusable(false);
        bt_resumeDownAll.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bt_resumeDownAll.setMaximumSize(new java.awt.Dimension(75, 73));
        bt_resumeDownAll.setMinimumSize(new java.awt.Dimension(75, 73));
        bt_resumeDownAll.setOpaque(false);
        bt_resumeDownAll.setPreferredSize(new java.awt.Dimension(75, 73));
        bt_resumeDownAll.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tbar_download.add(bt_resumeDownAll);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tbar_download, javax.swing.GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tbar_download, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Tải về", jPanel3);

        tbar_advancer.setFloatable(false);
        tbar_advancer.setRollover(true);
        tbar_advancer.setOpaque(false);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tbar_advancer, javax.swing.GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tbar_advancer, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab(" Nâng cao", jPanel4);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 597, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
    }// </editor-fold>//GEN-END:initComponents

    protected void addListenner() {
        MyListenner listenner = new MyListenner();
        bt_newProject.addActionListener(listenner);
        bt_archiveEx.addActionListener(listenner);
        bt_audioEx.addActionListener(listenner);
        bt_imgEx.addActionListener(listenner);
        bt_newProject_Wizard.addActionListener(listenner);
        bt_otherEx.addActionListener(listenner);
        bt_pauseDown1.addActionListener(listenner);
        bt_stopDownAll.addActionListener(listenner);
        bt_protocol.addActionListener(listenner);
        bt_resumeDownAll.addActionListener(listenner);
        bt_startDown1.addActionListener(listenner);;
        bt_startDownAll.addActionListener(listenner);
        bt_stopDown1.addActionListener(listenner);
        bt_textEx.addActionListener(listenner);
        bt_userdefinedEx.addActionListener(listenner);
        bt_videoEx.addActionListener(listenner);

        cb_archiveEx.addItemListener(listenner);
    }

    public void updateToolBar() {
        bt_startDown1.setEnabled(true);
        bt_stopDown1.setEnabled(false);
        bt_pauseDown1.setEnabled(false);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bt_archiveEx;
    private javax.swing.JButton bt_audioEx;
    private javax.swing.JButton bt_imgEx;
    private javax.swing.JButton bt_newProject;
    private javax.swing.JButton bt_newProject_Wizard;
    private javax.swing.JButton bt_otherEx;
    public javax.swing.JButton bt_pauseDown1;
    private javax.swing.JButton bt_protocol;
    public javax.swing.JButton bt_resumeDownAll;
    public javax.swing.JButton bt_startDown1;
    public javax.swing.JButton bt_startDownAll;
    public javax.swing.JButton bt_stopDown1;
    public javax.swing.JButton bt_stopDownAll;
    private javax.swing.JButton bt_textEx;
    private javax.swing.JButton bt_userdefinedEx;
    private javax.swing.JButton bt_videoEx;
    private javax.swing.JCheckBox cb_archiveEx;
    private javax.swing.JCheckBox cb_audioEx;
    private javax.swing.JCheckBox cb_imgEx;
    private javax.swing.JCheckBox cb_otherEx;
    private javax.swing.JCheckBox cb_textEx;
    private javax.swing.JCheckBox cb_userdefinedEx;
    private javax.swing.JCheckBox cb_videoEx;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar.Separator jSeparator4;
    private javax.swing.JToolBar.Separator jSeparator5;
    private javax.swing.JToolBar.Separator jSeparator6;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar tbar_advancer;
    private javax.swing.JToolBar tbar_download;
    private javax.swing.JToolBar tbar_mainMenu;
    private javax.swing.JToolBar tbar_option;
    // End of variables declaration//GEN-END:variables

    private class MyListenner implements ActionListener, ItemListener {

        public void actionPerformed(ActionEvent e) {
            String actionCommand = e.getActionCommand();

            if(actionCommand.equals("pushNewProject")) {
                Main.program.projectPropertyForm.defaultView("PROJECT");
                Main.program.projectPropertyForm.showForm(true);
            }
            if(actionCommand.equals("pushNewProject_Wizard")) {

            }
            if(actionCommand.equals("pushStartSelection")) {
               TreePath path = Main.program.mainForm.pnWorkArea.jTree1.getSelectionPath();
               int index = Main.program.mainForm.pnWorkArea.jTree1.getRowForPath(path);
                if(index > 0) {
                    Main.program.runProject(index - 1);
                    Main.program.mainForm.pnWorkArea.reloadTree();
                    bt_startDown1.setEnabled(false);

                    bt_pauseDown1.setEnabled(true);
                    bt_stopDown1.setEnabled(true);

                    bt_pauseDown1.setText("Tạm dừng");
                    bt_pauseDown1.setIcon(new ImageIcon("resource/tool/SupendDown.png"));
                }
            }
            if(actionCommand.equals("pushPauseSelection")) {
               TreePath path = Main.program.mainForm.pnWorkArea.jTree1.getSelectionPath();
               int index = Main.program.mainForm.pnWorkArea.jTree1.getRowForPath(path);
               int status = -1;
                if(index > 0) {
                    status = Main.program.getProject(index - 1).getStatus();
                }
               if(status == Project.PAUSE || status == Project.STOP) {
                    Main.program.resumeProject(index - 1);

                    bt_startDown1.setEnabled(false);

                    bt_stopDown1.setEnabled(true);

                    bt_pauseDown1.setText("Tạm dừng");
                    bt_pauseDown1.setIcon(new ImageIcon("resource/tool/SupendDown.png"));
               }

               if(status == Project.RUN) {
                    Main.program.pauseProject(index - 1);

                    bt_startDown1.setEnabled(true);

                    bt_pauseDown1.setText("Tiếp tục");
                    bt_pauseDown1.setIcon(new ImageIcon("resource/tool/ResumeDown.png"));
               }

               if(status == Project.NONE || status == Project.FINISHED) {

               }
               Main.program.mainForm.pnWorkArea.reloadTree();
            }

            if(actionCommand.equals("pushStopSelection")) {
               TreePath path = Main.program.mainForm.pnWorkArea.jTree1.getSelectionPath();
               int index = Main.program.mainForm.pnWorkArea.jTree1.getRowForPath(path);
                if(index > 0) {
                    Main.program.stopProject(index - 1);
                    Main.program.mainForm.pnWorkArea.reloadTree();
                    
                    bt_startDown1.setEnabled(true);
                    bt_pauseDown1.setEnabled(true);
                    
                    bt_stopDown1.setEnabled(false);

                    bt_pauseDown1.setText("Tiếp tục");
                    bt_pauseDown1.setIcon(new ImageIcon("resource/tool/ResumeDown.png"));
                }
            }

            if(actionCommand.equals("pushBtText")) {
                Main.program.projectPropertyForm.defaultView("TEXT");
                Main.program.projectPropertyForm.showForm(true);
            }
            if(actionCommand.equals("pushBtAudio")) {
                Main.program.projectPropertyForm.defaultView("AUDIO");
                Main.program.projectPropertyForm.showForm(true);
            }
            if(actionCommand.equals("pushBtVideo")) {
                Main.program.projectPropertyForm.defaultView("VIDEO");
                Main.program.projectPropertyForm.showForm(true);
            }
            if(actionCommand.equals("pushBtImg")) {
                Main.program.projectPropertyForm.defaultView("IMG");
                Main.program.projectPropertyForm.showForm(true);
            }
            if(actionCommand.equals("pushBtArchive")) {
                Main.program.projectPropertyForm.defaultView("ARCHIVE");
                Main.program.projectPropertyForm.showForm(true);
            }
            if(actionCommand.equals("pushBtUserdefined")) {
                Main.program.projectPropertyForm.defaultView("USERDEFINED");
                Main.program.projectPropertyForm.showForm(true);
            }
            if(actionCommand.equals("pushBtOther")) {

            }
            if(actionCommand.equals("pushBtProtocol")) {

            }

            if(actionCommand.equals("pushStartAll")) {
                Main.program.startAllProject();
                Main.program.mainForm.pnWorkArea.reloadTree();
                bt_startDown1.setEnabled(false);
                bt_startDownAll.setEnabled(false);
                bt_resumeDownAll.setEnabled(false);

                bt_stopDown1.setEnabled(true);
                bt_stopDownAll.setEnabled(true);
                bt_pauseDown1.setEnabled(true);
                
                bt_pauseDown1.setText("Tạm dừng");
                bt_pauseDown1.setIcon(new ImageIcon("resource/tool/SupendDown.png"));
            }
            if(actionCommand.equals("pushStopAll")) {
                Main.program.stopAllProject();
                Main.program.mainForm.pnWorkArea.reloadTree();
                bt_startDown1.setEnabled(true);
                bt_startDownAll.setEnabled(true);
                bt_pauseDown1.setEnabled(true);
                bt_resumeDownAll.setEnabled(true);

                bt_stopDown1.setEnabled(false);
                
                bt_stopDownAll.setEnabled(false);

                bt_pauseDown1.setText("Tiếp tục");
                bt_pauseDown1.setIcon(new ImageIcon("resource/tool/ResumeDown.png"));
            }

            if(actionCommand.equals("pushResumeAll")) {
                Main.program.startAllProject();
                Main.program.mainForm.pnWorkArea.reloadTree();
                bt_stopDownAll.setEnabled(true);
                bt_stopDown1.setEnabled(true);
                bt_pauseDown1.setEnabled(true);

                bt_startDown1.setEnabled(false);
                bt_startDownAll.setEnabled(false);
                bt_resumeDownAll.setEnabled(false);

                bt_pauseDown1.setText("Tạm dừng");
                bt_pauseDown1.setIcon(new ImageIcon("resource/tool/SupendDown.png"));
            }
        }

        public void itemStateChanged(ItemEvent e) {
            Object obj = e.getItemSelectable();
            if(obj == cb_archiveEx) {
                if(e.getStateChange() == 1) {
                    
                }
            }
        }

    }
}
